/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package DAO;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.AnnotationConfiguration;

/**
 *
 * @author walter
 */
public class Sesion {
    public Session session ;
    
    public Sesion(){
        session = null ;
        SessionFactory sessionFactory = new AnnotationConfiguration().configure().buildSessionFactory() ;
        session = sessionFactory.openSession() ;
    }
    
    public void close(){
        session.flush() ;
        session.close() ;
    }
    
    public void refresh(){
        session.flush() ;
        session.close() ;
        session = null ;
        SessionFactory sessionFactory = new AnnotationConfiguration().configure().buildSessionFactory() ;
        session = sessionFactory.openSession() ;
    }
}
